package com.hung.triple.registry;

import com.alibaba.nacos.api.naming.pojo.Instance;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * 服务提供者的信息
 *
 * @author Hung
 * @since 2022/9/18
 */
@Data
@NoArgsConstructor
public class ProviderBeanInfo {

    private String groupName;
    private String serviceName;
    private String version;
    /**
     * TODO 尝试拆分出来一个个字段
     * 补充信息(写入当前IP的 ZNode 的数据)，比如当前时间、超时时间等
     * 注，dubbo中的数据为 : dubbo://192.168.1.180:20880/cn.edu.zju.arc.qm.client.rpc.RuleService?anyhost=true&application=supervisor&bean.name=ServiceBean:cn.edu.zju.arc.qm.client.rpc.RuleService&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=cn.edu.zju.arc.qm.client.rpc.RuleService&logger=slf4j&methods=getAllWarningRules,getAllFieldsWeight,getAllMeasureRules&pid=27814&release=2.7.4.1&side=provider&timeout=2000&timestamp=1578399274345
     */
    private Map<String, Object> info = Maps.newHashMap();

    /**
     * Nacos 注册中心 实例
     * 如果不选用Nacos的话这里为null
     */
    private Instance instance;


    public void addInfo(String k, Object v) {
        info.put(k, v);
    }

    public ProviderBeanInfo(String groupName, String serviceName, String version) {
        this.groupName = groupName;
        this.serviceName = serviceName;
        this.version = version;
    }

}
